package com.xiongtian.springframework.context.event;

import com.xiongtian.springframework.beans.factory.BeanFactory;
import com.xiongtian.springframework.context.ApplicationEvent;
import com.xiongtian.springframework.context.ApplicationListener;

/**
 * @Author: xiongtian
 * @CreateTime: 2025-04-14  10:26
 * @Version: 1.0
 * @Description: 简单应用事件广播器
 */

public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster {

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }


    /**
     * 广播事件
     *
     * @param event the event to multicast
     */
    @SuppressWarnings("unchecked")
    @Override
    public void multicastEvent(ApplicationEvent event) {
        for (final ApplicationListener listener : getApplicationListeners(event)) {
            listener.onApplicationEvent(event);
        }

    }
}
